public class DeleteDuplicates {
    // 删除有序链表中重复的元素-I
    // https://www.nowcoder.com/practice/c087914fae584da886a0091e877f2c79?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page
    public ListNode deleteDuplicates (ListNode head) {
        // write code here
        ListNode pHead = new ListNode(-1);
        ListNode cur = pHead;
        ListNode cur2 = head;
        while (cur2 != null) {
            cur.next = cur2;
            cur = cur.next;
            int tmp = cur2.val;
            while (cur2 != null && cur2.val == tmp) {
                cur2 = cur2.next;
            }
        }
        cur.next = null;
        return pHead.next;
    }
}
